Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/extensions/extension_tabs_module.cc

Issue 8983012: Get rid of content::NavigationController in cc file and use "using" instead. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_tabs_module.h" 5 #include "chrome/browser/extensions/extension_tabs_module.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "content/public/browser/web_contents.h" 54 #include "content/public/browser/web_contents.h"
55 #include "skia/ext/image_operations.h" 55 #include "skia/ext/image_operations.h"
56 #include "skia/ext/platform_canvas.h" 56 #include "skia/ext/platform_canvas.h"
57 #include "third_party/skia/include/core/SkBitmap.h" 57 #include "third_party/skia/include/core/SkBitmap.h"
58 #include "ui/gfx/codec/jpeg_codec.h" 58 #include "ui/gfx/codec/jpeg_codec.h"
59 #include "ui/gfx/codec/png_codec.h" 59 #include "ui/gfx/codec/png_codec.h"
60 60
61 namespace keys = extension_tabs_module_constants; 61 namespace keys = extension_tabs_module_constants;
62 namespace errors = extension_manifest_errors; 62 namespace errors = extension_manifest_errors;
63 63
64 using content::NavigationController;
64 using content::NavigationEntry; 65 using content::NavigationEntry;
65 using content::OpenURLParams; 66 using content::OpenURLParams;
66 using content::Referrer; 67 using content::Referrer;
67 using content::WebContents; 68 using content::WebContents;
68 69
69 const int CaptureVisibleTabFunction::kDefaultQuality = 90; 70 const int CaptureVisibleTabFunction::kDefaultQuality = 90;
70 71
71 namespace { 72 namespace {
72 73
73 // |error_message| can optionally be passed in a will be set with an appropriate 74 // |error_message| can optionally be passed in a will be set with an appropriate
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 } else { 1066 } else {
1066 EXTENSION_FUNCTION_VALIDATE(tab_value->GetAsInteger(&tab_id)); 1067 EXTENSION_FUNCTION_VALIDATE(tab_value->GetAsInteger(&tab_id));
1067 } 1068 }
1068 1069
1069 int tab_index = -1; 1070 int tab_index = -1;
1070 TabStripModel* tab_strip = NULL; 1071 TabStripModel* tab_strip = NULL;
1071 if (!GetTabById(tab_id, profile(), include_incognito(), 1072 if (!GetTabById(tab_id, profile(), include_incognito(),
1072 NULL, &tab_strip, &contents, &tab_index, &error_)) { 1073 NULL, &tab_strip, &contents, &tab_index, &error_)) {
1073 return false; 1074 return false;
1074 } 1075 }
1075 content::NavigationController& controller = 1076 NavigationController& controller = contents->web_contents()->GetController();
1076 contents->web_contents()->GetController();
1077 1077
1078 // TODO(rafaelw): handle setting remaining tab properties: 1078 // TODO(rafaelw): handle setting remaining tab properties:
1079 // -title 1079 // -title
1080 // -favIconUrl 1080 // -favIconUrl
1081 1081
1082 // Navigate the tab to a new location if the url is different. 1082 // Navigate the tab to a new location if the url is different.
1083 std::string url_string; 1083 std::string url_string;
1084 if (update_props->HasKey(keys::kUrlKey)) { 1084 if (update_props->HasKey(keys::kUrlKey)) {
1085 EXTENSION_FUNCTION_VALIDATE(update_props->GetString( 1085 EXTENSION_FUNCTION_VALIDATE(update_props->GetString(
1086 keys::kUrlKey, &url_string)); 1086 keys::kUrlKey, &url_string));
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 &DetectTabLanguageFunction::GotLanguage, this, 1632 &DetectTabLanguageFunction::GotLanguage, this,
1633 helper->language_state().original_language())); 1633 helper->language_state().original_language()));
1634 return true; 1634 return true;
1635 } 1635 }
1636 // The tab contents does not know its language yet. Let's wait until it 1636 // The tab contents does not know its language yet. Let's wait until it
1637 // receives it, or until the tab is closed/navigates to some other page. 1637 // receives it, or until the tab is closed/navigates to some other page.
1638 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 1638 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
1639 content::Source<WebContents>(contents->web_contents())); 1639 content::Source<WebContents>(contents->web_contents()));
1640 registrar_.Add( 1640 registrar_.Add(
1641 this, content::NOTIFICATION_TAB_CLOSING, 1641 this, content::NOTIFICATION_TAB_CLOSING,
1642 content::Source<content::NavigationController>( 1642 content::Source<NavigationController>(
1643 &(contents->web_contents()->GetController()))); 1643 &(contents->web_contents()->GetController())));
1644 registrar_.Add( 1644 registrar_.Add(
1645 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 1645 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
1646 content::Source<content::NavigationController>( 1646 content::Source<NavigationController>(
1647 &(contents->web_contents()->GetController()))); 1647 &(contents->web_contents()->GetController())));
1648 return true; 1648 return true;
1649 } 1649 }
1650 1650
1651 void DetectTabLanguageFunction::Observe( 1651 void DetectTabLanguageFunction::Observe(
1652 int type, 1652 int type,
1653 const content::NotificationSource& source, 1653 const content::NotificationSource& source,
1654 const content::NotificationDetails& details) { 1654 const content::NotificationDetails& details) {
1655 std::string language; 1655 std::string language;
1656 if (type == chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED) 1656 if (type == chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED)
1657 language = *content::Details<std::string>(details).ptr(); 1657 language = *content::Details<std::string>(details).ptr();
1658 1658
1659 registrar_.RemoveAll(); 1659 registrar_.RemoveAll();
1660 1660
1661 // Call GotLanguage in all cases as we want to guarantee the callback is 1661 // Call GotLanguage in all cases as we want to guarantee the callback is
1662 // called for every API call the extension made. 1662 // called for every API call the extension made.
1663 GotLanguage(language); 1663 GotLanguage(language);
1664 } 1664 }
1665 1665
1666 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { 1666 void DetectTabLanguageFunction::GotLanguage(const std::string& language) {
1667 result_.reset(Value::CreateStringValue(language.c_str())); 1667 result_.reset(Value::CreateStringValue(language.c_str()));
1668 SendResponse(true); 1668 SendResponse(true);
1669 1669
1670 Release(); // Balanced in Run() 1670 Release(); // Balanced in Run()
1671 } 1671 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_navigation_observer.cc ('k') | chrome/browser/extensions/isolated_app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698