<commit_before>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "app/l10n_util.h"
#include "base/command_line.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/debugger/devtools_client_host.h"
#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"

DevToolsWindow::DevToolsWindow(Profile* profile)
    : TabStripModelObserver(),
      inspected_tab_closing_(false) {
  static bool g_prefs_registered = false;
  if (!g_prefs_registered) {
    std::wstring window_pref(prefs::kBrowserWindowPlacement);
    window_pref.append(L"_");
    window_pref.append(L"DevToolsApp");
    PrefService* prefs = g_browser_process->local_state();
    prefs->RegisterDictionaryPref(window_pref.c_str());
    g_prefs_registered = true;
  }
  
  browser_.reset(Browser::CreateForApp(L"DevToolsApp", profile, false));
  GURL contents(std::string(chrome::kChromeUIDevToolsURL) + "devtools.html");
  browser_->AddTabWithURL(contents, GURL(), PageTransition::START_PAGE, true,
                          -1, false, NULL);
  tab_contents_ = browser_->GetSelectedTabContents();
  browser_->tabstrip_model()->AddObserver(this);
}

DevToolsWindow::~DevToolsWindow() {
}

void DevToolsWindow::Show() {
  browser_->window()->Show();
  tab_contents_->view()->SetInitialFocus();
}

DevToolsWindow* DevToolsWindow::AsDevToolsWindow() {
  return this; 
}<commit_msg>DevTools: Provide nice initial location/size for the devtools window.<commit_after>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "app/l10n_util.h"
#include "base/command_line.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/debugger/devtools_client_host.h"
#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"

DevToolsWindow::DevToolsWindow(Profile* profile)
    : TabStripModelObserver(),
      inspected_tab_closing_(false) {
  static std::wstring g_wp_key = L"";
  if (g_wp_key.empty()) {
    // TODO(pfeldman): Make browser's getter for this key static.
    g_wp_key.append(prefs::kBrowserWindowPlacement);
    g_wp_key.append(L"_");
    g_wp_key.append(L"DevToolsApp");

    PrefService* prefs = g_browser_process->local_state();
    prefs->RegisterDictionaryPref(g_wp_key.c_str());
    
    const DictionaryValue* wp_pref = prefs->GetDictionary(g_wp_key.c_str());
    if (!wp_pref) {
      DictionaryValue* defaults = prefs->GetMutableDictionary(
          g_wp_key.c_str());
      defaults->SetInteger(L"left", 100);
      defaults->SetInteger(L"top", 100);
      defaults->SetInteger(L"right", 740);
      defaults->SetInteger(L"bottom", 740);
      defaults->SetBoolean(L"maximized", false);
      defaults->SetBoolean(L"always_on_top", false);
    }
  }

  browser_.reset(Browser::CreateForApp(L"DevToolsApp", profile, false));
  GURL contents(std::string(chrome::kChromeUIDevToolsURL) + "devtools.html");
  browser_->AddTabWithURL(contents, GURL(), PageTransition::START_PAGE, true,
                          -1, false, NULL);
  tab_contents_ = browser_->GetSelectedTabContents();
  browser_->tabstrip_model()->AddObserver(this);
}

DevToolsWindow::~DevToolsWindow() {
}

void DevToolsWindow::Show() {
  browser_->window()->Show();
  tab_contents_->view()->SetInitialFocus();
}

DevToolsWindow* DevToolsWindow::AsDevToolsWindow() {
  return this; 
}
{'fraction_non_alphanumeric': 0.1376629316258861, 'fraction_numerical': 0.0059455751200548825, 'mean_word_length': 5.293525179856115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6876689', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1413, 'n_words': 243}